package com.pig4cloud.pigx.contract.config.mq;

import com.pig4cloud.pigx.contract.config.contract.ContractConfig;
import com.pig4cloud.pigx.contract.constant.ContractMqConstants;
import lombok.AllArgsConstructor;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 队列定义
 *
 * @since 2022/8/17 19:12
 */
@Configuration
@AllArgsConstructor
public class ContractMqConfig {

    private final ContractConfig contractConfig;

    /**
     * contract.order.new
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractOrderNewExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_ORDER_NEW);
    }

    /**
     * contract.order.new
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractOrderNewQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_ORDER_NEW);
    }

    /**
     * contract.order.new
     *
     * @param contractOrderNewExchange 交换机
     * @param contractOrderNewQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractOrderNew(FanoutExchange contractOrderNewExchange, Queue contractOrderNewQueue) {
        return BindingBuilder.bind(contractOrderNewQueue)
                .to(contractOrderNewExchange);
    }

    /**
     * contract.order.new.depth.map
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractOrderNewDepthMapExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_ORDER_NEW_DEPTH_MAP);
    }

    /**
     * contract.order.new.depth.map
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractOrderNewDepthMapQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_ORDER_NEW_DEPTH_MAP);
    }

    /**
     * contract.order.new.depth.map
     *
     * @param contractOrderNewDepthMapExchange 交换机
     * @param contractOrderNewDepthMapQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractOrderNewDepthMap(FanoutExchange contractOrderNewDepthMapExchange, Queue contractOrderNewDepthMapQueue) {
        return BindingBuilder.bind(contractOrderNewDepthMapQueue)
                .to(contractOrderNewDepthMapExchange);
    }

    /**
     * contract.order.new.robot.k_line
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractOrderNewRobotKLineExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_ORDER_NEW_ROBOT_K_LINE);
    }

    /**
     * contract.order.new.robot.k_line
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractOrderNewRobotKLineQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_ORDER_NEW_ROBOT_K_LINE);
    }

    /**
     * contract.order.new.robot.k_line
     *
     * @param contractOrderNewRobotKLineExchange 交换机
     * @param contractOrderNewRobotKLineQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractOrderNewRobot(FanoutExchange contractOrderNewRobotKLineExchange, Queue contractOrderNewRobotKLineQueue) {
        return BindingBuilder.bind(contractOrderNewRobotKLineQueue)
                .to(contractOrderNewRobotKLineExchange);
    }

    /**
     * contract.order.new.robot.k_line.depth.map
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractOrderNewRobotKLineDepthMapExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_ORDER_NEW_ROBOT_K_LINE_DEPTH_MAP);
    }

    /**
     * contract.order.new.robot.k_line.depth.map
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractOrderNewRobotKLineDepthMapQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_ORDER_NEW_ROBOT_K_LINE_DEPTH_MAP);
    }

    /**
     * contract.order.new.robot.k_line.depth.map
     *
     * @param contractOrderNewRobotKLineDepthMapExchange 交换机
     * @param contractOrderNewRobotKLineDepthMapQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractOrderNewDepthMapRobot(FanoutExchange contractOrderNewRobotKLineDepthMapExchange, Queue contractOrderNewRobotKLineDepthMapQueue) {
        return BindingBuilder.bind(contractOrderNewRobotKLineDepthMapQueue)
                .to(contractOrderNewRobotKLineDepthMapExchange);
    }

    /**
     * contract.trade.new
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractTradeNewExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_TRADE_NEW);
    }

    /**
     * contract.trade.new
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractTradeNewQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_TRADE_NEW);
    }


    /**
     * contract.trade.new
     *
     * @param contractTradeNewExchange 交换机
     * @param contractTradeNewQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractTradeNew(FanoutExchange contractTradeNewExchange, Queue contractTradeNewQueue) {
        return BindingBuilder.bind(contractTradeNewQueue)
                .to(contractTradeNewExchange);
    }

    /**
     * contract.trade.new.depth.map
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractTradeNewDepthMapExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_TRADE_NEW_DEPTH_MAP);
    }

    /**
     * contract.trade.new.depth.map
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractTradeNewDepthMapQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_TRADE_NEW_DEPTH_MAP);
    }

    /**
     * contract.trade.new.depth.map
     *
     * @param contractTradeNewDepthMapExchange 交换机
     * @param contractTradeNewDepthMapQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractTradeNewDepthMap(FanoutExchange contractTradeNewDepthMapExchange, Queue contractTradeNewDepthMapQueue) {
        return BindingBuilder.bind(contractTradeNewDepthMapQueue)
                .to(contractTradeNewDepthMapExchange);
    }

    /**
     * contract.trade.new.robot.k_line
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractTradeNewRobotKLineExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_TRADE_NEW_ROBOT_K_LINE);
    }

    /**
     * contract.trade.new.robot.k_line
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractTradeNewRobotKLineQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_TRADE_NEW_ROBOT_K_LINE);
    }

    /**
     * contract.trade.new.robot.k_line
     *
     * @param contractTradeNewRobotKLineExchange 交换机
     * @param contractTradeNewRobotKLineQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractTradeNewRobotKLine(FanoutExchange contractTradeNewRobotKLineExchange, Queue contractTradeNewRobotKLineQueue) {
        return BindingBuilder.bind(contractTradeNewRobotKLineQueue)
                .to(contractTradeNewRobotKLineExchange);
    }

    /**
     * contract.trade.new.robot.k_line.depth.map
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractTradeNewRobotKLineDepthMapExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_TRADE_NEW_ROBOT_K_LINE_DEPTH_MAP);
    }

    /**
     * contract.trade.new.robot.k_line.depth.map
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractTradeNewRobotKLineDepthMapQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_TRADE_NEW_ROBOT_K_LINE_DEPTH_MAP);
    }

    /**
     * contract.trade.new.robot.k_line.depth.map
     *
     * @param contractTradeNewRobotKLineDepthMapExchange 交换机
     * @param contractTradeNewRobotKLineDepthMapQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractTradeNewRobotKLineDepthMap(FanoutExchange contractTradeNewRobotKLineDepthMapExchange, Queue contractTradeNewRobotKLineDepthMapQueue) {
        return BindingBuilder.bind(contractTradeNewRobotKLineDepthMapQueue)
                .to(contractTradeNewRobotKLineDepthMapExchange);
    }

    /**
     * 延迟交换机 contract.order.cancel.market
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractOrderCancelMarketExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_DELAY_CONTRACT_ORDER_CANCEL_MARKET);
    }

    /**
     * 延迟队列 contract.order.cancel.market
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractOrderCancelMarketQueue() {
        return QueueBuilder.durable(ContractMqConstants.QUEUE_FANOUT_DELAY_CONTRACT_ORDER_CANCEL_MARKET)
                .deadLetterExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_ORDER_CANCEL)
                .deadLetterRoutingKey("")
                .ttl(contractConfig.getOrder().getMarketCancelDelay())
                .build();
    }

    /**
     * contract.order.cancel.market
     *
     * @param contractOrderCancelMarketExchange 交换机
     * @param contractOrderCancelMarketQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractOrderCancelMarket(FanoutExchange contractOrderCancelMarketExchange, Queue contractOrderCancelMarketQueue) {
        return BindingBuilder.bind(contractOrderCancelMarketQueue)
                .to(contractOrderCancelMarketExchange);
    }

    /**
     * contract.order.cancel
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractOrderCancelExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_ORDER_CANCEL);
    }

    /**
     * contract.order.cancel
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractOrderCancelQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_ORDER_CANCEL);
    }

    /**
     * contract.order.cancel
     *
     * @param contractOrderCancelExchange 交换机
     * @param contractOrderCancelQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractOrderCancel(FanoutExchange contractOrderCancelExchange, Queue contractOrderCancelQueue) {
        return BindingBuilder.bind(contractOrderCancelQueue)
                .to(contractOrderCancelExchange);
    }

    /**
     * contract.order.cancel.depth.map
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractOrderCancelDepthMapExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_ORDER_CANCEL_DEPTH_MAP);
    }

    /**
     * contract.order.cancel.depth.map
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractOrderCancelDepthMapQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_ORDER_CANCEL_DEPTH_MAP);
    }

    /**
     * contract.order.cancel.depth.map
     *
     * @param contractOrderCancelDepthMapExchange 交换机
     * @param contractOrderCancelDepthMapQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractOrderCancelDepthMap(FanoutExchange contractOrderCancelDepthMapExchange, Queue contractOrderCancelDepthMapQueue) {
        return BindingBuilder.bind(contractOrderCancelDepthMapQueue)
                .to(contractOrderCancelDepthMapExchange);
    }

    /**
     * contract.position.liquidate.isolate.check.triggerd，
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractPositionLiquidateIsolateCheckTriggerExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_POSITION_LIQUIDATE_ISOLATE_CHECK_TRIGGER);
    }

    /**
     * contract.position.liquidate.isolate.check.trigger
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractPositionLiquidateIsolateCheckTriggerQueue() {
        return QueueBuilder.durable(ContractMqConstants.QUEUE_FANOUT_CONTRACT_POSITION_LIQUIDATE_ISOLATE_CHECK_TRIGGER)
                .ttl(10000)
                .build();
    }

    /**
     * contract.position.liquidate.isolate.check.trigger
     *
     * @param contractPositionLiquidateIsolateCheckTriggerExchange 交换机
     * @param contractPositionLiquidateIsolateCheckTriggerQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractPositionLiquidateCheckTrigger(FanoutExchange contractPositionLiquidateIsolateCheckTriggerExchange, Queue contractPositionLiquidateIsolateCheckTriggerQueue) {
        return BindingBuilder.bind(contractPositionLiquidateIsolateCheckTriggerQueue)
                .to(contractPositionLiquidateIsolateCheckTriggerExchange);
    }

    /**
     * contract.position.liquidate.isolate.check
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractPositionLiquidateIsolateCheckExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_POSITION_LIQUIDATE_ISOLATE_CHECK);
    }

    /**
     * contract.position.liquidate.isolate.check
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractPositionLiquidateIsolateCheckQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_POSITION_LIQUIDATE_ISOLATE_CHECK);
    }

    /**
     * contract.position.liquidate.isolate.check
     *
     * @param contractPositionLiquidateIsolateCheckExchange 交换机
     * @param contractPositionLiquidateIsolateCheckQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractPositionLiquidateCheck(FanoutExchange contractPositionLiquidateIsolateCheckExchange, Queue contractPositionLiquidateIsolateCheckQueue) {
        return BindingBuilder.bind(contractPositionLiquidateIsolateCheckQueue)
                .to(contractPositionLiquidateIsolateCheckExchange);
    }

    /**
     * contract.position.liquidate.handle
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractPositionLiquidateHandleExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_POSITION_LIQUIDATE_HANDLE);
    }

    /**
     * contract.position.liquidate.handle
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractPositionLiquidateHandleQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_POSITION_LIQUIDATE_HANDLE);
    }

    /**
     * contract.position.liquidate.handle
     *
     * @param contractPositionLiquidateHandleExchange 交换机
     * @param contractPositionLiquidateHandleQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractPositionLiquidateHandle(FanoutExchange contractPositionLiquidateHandleExchange, Queue contractPositionLiquidateHandleQueue) {
        return BindingBuilder.bind(contractPositionLiquidateHandleQueue)
                .to(contractPositionLiquidateHandleExchange);
    }

    /**
     * contract.stop_order.check.trigger
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractStopOrderCheckTriggerExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_STOP_ORDER_CHECK_TRIGGER);
    }

    /**
     * contract.stop_order.check.trigger
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractStopOrderCheckTriggerQueue() {
        return QueueBuilder.durable(ContractMqConstants.QUEUE_FANOUT_CONTRACT_STOP_ORDER_CHECK_TRIGGER)
                .ttl(10000)
                .build();
    }

    /**
     * contract.stop_order.check.trigger
     *
     * @param contractStopOrderCheckTriggerExchange 交换机
     * @param contractStopOrderCheckTriggerQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractStopOrderCheckTrigger(FanoutExchange contractStopOrderCheckTriggerExchange, Queue contractStopOrderCheckTriggerQueue) {
        return BindingBuilder.bind(contractStopOrderCheckTriggerQueue)
                .to(contractStopOrderCheckTriggerExchange);
    }

    /**
     * contract.stop_order.check
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractStopOrderCheckExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_STOP_ORDER_CHECK);
    }

    /**
     * contract.stop_order.check
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractStopOrderCheckQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_STOP_ORDER_CHECK);
    }

    /**
     * contract.stop_order.check
     *
     * @param contractStopOrderCheckExchange 交换机
     * @param contractStopOrderCheckQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractStopOrderCheck(FanoutExchange contractStopOrderCheckExchange, Queue contractStopOrderCheckQueue) {
        return BindingBuilder.bind(contractStopOrderCheckQueue)
                .to(contractStopOrderCheckExchange);
    }

    /**
     * contract.stop_order.handle
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractStopOrderHandleExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_STOP_ORDER_HANDLE);
    }

    /**
     * contract.stop_order.handle
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractStopOrderHandleQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_STOP_ORDER_HANDLE);
    }

    /**
     * contract.stop_order.handle
     *
     * @param contractStopOrderHandleExchange 交换机
     * @param contractStopOrderHandleQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractStopOrderHandle(FanoutExchange contractStopOrderHandleExchange, Queue contractStopOrderHandleQueue) {
        return BindingBuilder.bind(contractStopOrderHandleQueue)
                .to(contractStopOrderHandleExchange);
    }

    /**
     * contract.stop_order.cancel
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractStopOrderCancelExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_STOP_ORDER_CANCEL);
    }

    /**
     * contract.stop_order.cancel
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractStopOrderCancelQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_STOP_ORDER_CANCEL);
    }

    /**
     * contract.stop_order.cancel
     *
     * @param contractStopOrderCancelExchange 交换机
     * @param contractStopOrderCancelQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractStopOrderCancel(FanoutExchange contractStopOrderCancelExchange, Queue contractStopOrderCancelQueue) {
        return BindingBuilder.bind(contractStopOrderCancelQueue)
                .to(contractStopOrderCancelExchange);
    }

    /**
     * 延迟交换机 contract.delay.order.expire
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractDelayOrderExpireExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_DELAY_CONTRACT_ORDER_EXPIRE);
    }

    /**
     * 延迟队列 contract.delay.order.expire
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractDelayOrderExpireQueue() {
        return QueueBuilder.durable(ContractMqConstants.QUEUE_FANOUT_DELAY_CONTRACT_ORDER_EXPIRE)
                .deadLetterExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_ORDER_EXPIRE)
                .deadLetterRoutingKey("")
                .ttl(contractConfig.getOrder().getExpire())
                .build();
    }

    /**
     * contract.delay.order.expire
     *
     * @param contractDelayOrderExpireExchange 交换机
     * @param contractDelayOrderExpireQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandDelayOrderExpire(FanoutExchange contractDelayOrderExpireExchange, Queue contractDelayOrderExpireQueue) {
        return BindingBuilder.bind(contractDelayOrderExpireQueue)
                .to(contractDelayOrderExpireExchange);
    }

    /**
     * contract.order.expire
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractOrderExpireExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_ORDER_EXPIRE);
    }

    /**
     * contract.order.expire
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractOrderExpireQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_ORDER_EXPIRE);
    }

    /**
     * contract.order.expire
     *
     * @param contractOrderExpireExchange 交换机
     * @param contractOrderExpireQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractOrderExpire(FanoutExchange contractOrderExpireExchange, Queue contractOrderExpireQueue) {
        return BindingBuilder.bind(contractOrderExpireQueue)
                .to(contractOrderExpireExchange);
    }

    /**
     * contract.order.expire.depth.map
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractOrderExpireDepthMapExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_ORDER_EXPIRE_DEPTH_MAP);
    }

    /**
     * contract.order.expire.depth.map
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractOrderExpireDepthMapQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_ORDER_EXPIRE_DEPTH_MAP);
    }

    /**
     * contract.order.expire.depth.map
     *
     * @param contractOrderExpireDepthMapExchange 交换机
     * @param contractOrderExpireDepthMapQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractOrderExpireDepthMap(FanoutExchange contractOrderExpireDepthMapExchange, Queue contractOrderExpireDepthMapQueue) {
        return BindingBuilder.bind(contractOrderExpireDepthMapQueue)
                .to(contractOrderExpireDepthMapExchange);
    }

    /**
     * contract.position.close.all
     *
     * @return {@link FanoutExchange}
     * @since 2022/8/17 20:39
     */
    @Bean
    public FanoutExchange contractPositionCloseAllExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_POSITION_CLOSE_ALL);
    }

    /**
     * contract.position.close.all
     *
     * @return {@link Queue}
     * @since 2022/8/17 20:39
     */
    @Bean
    public Queue contractPositionCloseAllQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_POSITION_CLOSE_ALL);
    }

    /**
     * contract.position.close.all
     *
     * @param contractPositionCloseAllExchange 交换机
     * @param contractPositionCloseAllQueue    队列
     * @return {@link Binding}
     * @since 2022/8/17 20:43
     */
    @Bean
    public Binding bandContractPositionCloseAll(FanoutExchange contractPositionCloseAllExchange, Queue contractPositionCloseAllQueue) {
        return BindingBuilder.bind(contractPositionCloseAllQueue)
                .to(contractPositionCloseAllExchange);
    }

    /**
     * 交易记录交换机 contract.init.trade
     *
     * @return {@link FanoutExchange}
     * @since 2022/9/8 15:39
     */
    @Bean
    public FanoutExchange contractInitTradeExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_INIT_TRADE);
    }

    /**
     * 交易记录队列 contract.init.trade
     *
     * @return {@link Queue}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Queue contractInitTradeQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_INIT_TRADE);
    }

    /**
     * contract.init.trade
     *
     * @param contractInitTradeExchange 交换机
     * @param contractInitTradeQueue    队列
     * @return {@link Binding}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Binding bandContractInitTrade(FanoutExchange contractInitTradeExchange, Queue contractInitTradeQueue) {
        return BindingBuilder.bind(contractInitTradeQueue)
                .to(contractInitTradeExchange);
    }

    /**
     * contract.position.margin.detail
     *
     * @return {@link FanoutExchange}
     * @since 2022/9/8 15:39
     */
    @Bean
    public FanoutExchange contractPositionMarginDetailExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_POSITION_MARGIN_DETAIL);
    }

    /**
     * contract.position.margin.detail
     *
     * @return {@link Queue}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Queue contractPositionMarginDetailQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_POSITION_MARGIN_DETAIL);
    }

    /**
     * contract.position.margin.detail
     *
     * @param contractPositionMarginDetailExchange 交换机
     * @param contractPositionMarginDetailQueue    队列
     * @return {@link Binding}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Binding bandContractPositionMarginDetail(FanoutExchange contractPositionMarginDetailExchange, Queue contractPositionMarginDetailQueue) {
        return BindingBuilder.bind(contractPositionMarginDetailQueue)
                .to(contractPositionMarginDetailExchange);
    }

    /**
     * contract.position.margin.append
     *
     * @return {@link FanoutExchange}
     * @since 2022/9/8 15:39
     */
    @Bean
    public FanoutExchange contractPositionMarginAppendExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_POSITION_MARGIN_APPEND);
    }

    /**
     * contract.position.margin.append
     *
     * @return {@link Queue}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Queue contractPositionMarginAppendQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_POSITION_MARGIN_APPEND);
    }

    /**
     * contract.position.margin.append
     *
     * @param contractPositionMarginAppendExchange 交换机
     * @param contractPositionMarginAppendQueue    队列
     * @return {@link Binding}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Binding bandContractPositionMarginAppend(FanoutExchange contractPositionMarginAppendExchange, Queue contractPositionMarginAppendQueue) {
        return BindingBuilder.bind(contractPositionMarginAppendQueue)
                .to(contractPositionMarginAppendExchange);
    }


    /**
     * contract.email.liquidate
     *
     * @return {@link FanoutExchange}
     * @since 2022/9/8 15:39
     */
    @Bean
    public FanoutExchange contractEmailLiquidateExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_EMAIL_LIQUIDATE);
    }

    /**
     * contract.email.liquidate
     *
     * @return {@link Queue}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Queue contractEmailLiquidateQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_EMAIL_LIQUIDATE);
    }

    /**
     * contract.email.liquidate
     *
     * @param contractEmailLiquidateExchange 交换机
     * @param contractEmailLiquidateQueue    队列
     * @return {@link Binding}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Binding bandContractEmailLiquidate(FanoutExchange contractEmailLiquidateExchange, Queue contractEmailLiquidateQueue) {
        return BindingBuilder.bind(contractEmailLiquidateQueue)
                .to(contractEmailLiquidateExchange);
    }

    /**
     * contract.email.margin.check
     *
     * @return {@link FanoutExchange}
     * @since 2022/9/8 15:39
     */
    @Bean
    public FanoutExchange contractEmailMarginCheckExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_EMAIL_MARGIN_CHECK);
    }

    /**
     * contract.email.margin.check
     *
     * @return {@link Queue}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Queue contractEmailMarginCheckQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_EMAIL_MARGIN_CHECK);
    }

    /**
     * contract.email.margin.check
     *
     * @param contractEmailMarginCheckExchange 交换机
     * @param contractEmailMarginCheckQueue    队列
     * @return {@link Binding}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Binding bandContractEmailMarginCheck(FanoutExchange contractEmailMarginCheckExchange, Queue contractEmailMarginCheckQueue) {
        return BindingBuilder.bind(contractEmailMarginCheckQueue)
                .to(contractEmailMarginCheckExchange);
    }


    /**
     * contract.position.margin.check.trigger
     *
     * @return {@link FanoutExchange}
     * @since 2022/9/8 15:39
     */
    @Bean
    public FanoutExchange contractPositionMarginCheckTriggerExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_POSITION_MARGIN_CHECK_TRIGGER);
    }

    /**
     * contract.position.margin.check.trigger
     *
     * @return {@link Queue}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Queue contractPositionMarginCheckTriggerQueue() {
        return QueueBuilder.durable(ContractMqConstants.QUEUE_FANOUT_CONTRACT_POSITION_MARGIN_CHECK_TRIGGER)
                .ttl(10000)
                .build();
    }

    /**
     * contract.position.margin.check.trigger
     *
     * @param contractPositionMarginCheckTriggerExchange 交换机
     * @param contractPositionMarginCheckTriggerQueue    队列
     * @return {@link Binding}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Binding bandContractPositionMarginCheckTrigger(FanoutExchange contractPositionMarginCheckTriggerExchange, Queue contractPositionMarginCheckTriggerQueue) {
        return BindingBuilder.bind(contractPositionMarginCheckTriggerQueue)
                .to(contractPositionMarginCheckTriggerExchange);
    }

    /**
     * contract.order.migrate
     *
     * @return {@link FanoutExchange}
     * @since 2022/9/8 15:39
     */
    @Bean
    public FanoutExchange contractOrderMigrateExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_ORDER_MIGRATE);
    }

    /**
     * contract.order.migrate
     *
     * @return {@link Queue}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Queue contractOrderMigrateQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_ORDER_MIGRATE);
    }

    /**
     * contract.order.migrate
     *
     * @param contractOrderMigrateExchange 交换机
     * @param contractOrderMigrateQueue    队列
     * @return {@link Binding}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Binding bandContractOrderMigrate(FanoutExchange contractOrderMigrateExchange, Queue contractOrderMigrateQueue) {
        return BindingBuilder.bind(contractOrderMigrateQueue)
                .to(contractOrderMigrateExchange);
    }

    /**
     * contract.position.migrate
     *
     * @return {@link FanoutExchange}
     * @since 2022/9/8 15:39
     */
    @Bean
    public FanoutExchange contractPositionMigrateExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_POSITION_MIGRATE);
    }

    /**
     * contract.position.migrate
     *
     * @return {@link Queue}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Queue contractPositionMigrateQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_POSITION_MIGRATE);
    }

    /**
     * contract.position.migrate
     *
     * @param contractPositionMigrateExchange 交换机
     * @param contractPositionMigrateQueue    队列
     * @return {@link Binding}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Binding bandContractPositionMigrate(FanoutExchange contractPositionMigrateExchange, Queue contractPositionMigrateQueue) {
        return BindingBuilder.bind(contractPositionMigrateQueue)
                .to(contractPositionMigrateExchange);
    }

    /**
     * contract.stop_order.migrate
     *
     * @return {@link FanoutExchange}
     * @since 2022/9/8 15:39
     */
    @Bean
    public FanoutExchange contractStopOrderMigrateExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_STOP_ORDER_MIGRATE);
    }

    /**
     * contract.stop_order.migrate
     *
     * @return {@link Queue}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Queue contractStopOrderMigrateQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_STOP_ORDER_MIGRATE);
    }

    /**
     * contract.stop_order.migrate
     *
     * @param contractStopOrderMigrateExchange 交换机
     * @param contractStopOrderMigrateQueue    队列
     * @return {@link Binding}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Binding bandContractStopOrderMigrate(FanoutExchange contractStopOrderMigrateExchange, Queue contractStopOrderMigrateQueue) {
        return BindingBuilder.bind(contractStopOrderMigrateQueue)
                .to(contractStopOrderMigrateExchange);
    }

    /**
     * 资金费率任务 交换机 rate.settlement.job
     *
     * @return {@link FanoutExchange}
     * @since 2022/9/8 15:39
     */
    @Bean
    public FanoutExchange rateSettlementJobExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_RATE_SETTLEMENT_JOB);
    }

    /**
     * 资金费率任务 队列 rate.settlement.job
     *
     * @return {@link Queue}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Queue rateSettlementJobQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_RATE_SETTLEMENT_JOB);
    }

    /**
     * contract.init.trade
     *
     * @param rateSettlementJobExchange 交换机
     * @param rateSettlementJobQueue    队列
     * @return {@link Binding}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Binding bandRateSettlementJob(FanoutExchange rateSettlementJobExchange, Queue rateSettlementJobQueue) {
        return BindingBuilder.bind(rateSettlementJobQueue)
                .to(rateSettlementJobExchange);
    }

    /**
     * contract.position.cross.calculate
     *
     * @return {@link FanoutExchange}
     * @since 2022/9/8 15:39
     */
    @Bean
    public FanoutExchange contractPositionCrossCalculateExchange() {
        return new FanoutExchange(ContractMqConstants.EXCHANGE_FANOUT_CONTRACT_POSITION_CROSS_CALCULATE);
    }

    /**
     * contract.position.cross.calculate
     *
     * @return {@link Queue}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Queue contractPositionCrossCalculateQueue() {
        return new Queue(ContractMqConstants.QUEUE_FANOUT_CONTRACT_POSITION_CROSS_CALCULATE);
    }

    /**
     * contract.position.cross.calculate
     *
     * @param contractPositionCrossCalculateExchange 交换机
     * @param contractPositionCrossCalculateQueue    队列
     * @return {@link Binding}
     * @since 2022/9/8 15:39
     */
    @Bean
    public Binding bandContractPositionCrossCalculate(FanoutExchange contractPositionCrossCalculateExchange, Queue contractPositionCrossCalculateQueue) {
        return BindingBuilder.bind(contractPositionCrossCalculateQueue)
                .to(contractPositionCrossCalculateExchange);
    }
}
